/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package figuras;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.scene.input.MouseEvent;
import javafx.scene.control.Label;
import javafx.scene.text.Font;
import javafx.scene.control.Button;
import javafx.scene.Group;

/**
 * @author Administrador
 */
 var imgXs;
 var imgYs;
var cont:Number;
var contador=Label {
        layoutX:10
        layoutY:300
	text: bind "{cont as Number}"
        font: Font {
        name: "Bitstream Vera Sans Bold"
        size: 28
    }
}

 var images = [
            Image { url: "{__DIR__}cajate.png" },
            Image { url: "{__DIR__}dado.png" },
            Image { url: "{__DIR__}discos.png" }
            Image { url: "{__DIR__}gorrocumple.png" },
            Image { url: "{__DIR__}lata.png" },
            Image { url: "{__DIR__}late.png" }
            Image { url: "{__DIR__}pelota.png" },
            Image { url: "{__DIR__}tarropapa.png" },
            Image { url: "{__DIR__}torrecd.png" },
            Image { url: "{__DIR__}vela.png" }
            Image { url: "{__DIR__}cone.png" },
            Image { url: "{__DIR__}prismauno.png" },

        ]
        ;


var count: Integer = 1;
var cajate=ImageView{
var imgX : Number = 850;
var imgY : Number = 150;
var startX : Number;
var startY : Number ;
var distX : Number;
var distY : Number ;
var ct:Boolean;
var cta:Boolean;
                       x:bind imgX;
                       y:bind imgY;
                        fitWidth:150
                        fitHeight:100
                        image : images[0]
                           onMousePressed: function( e: MouseEvent ):Void {
                        startX = e.x;

                        startY = e.y;

                        distX = startX - imgX;

                        distY = startY - imgY;
                        }
                        onMouseDragged: function( e: MouseEvent ):Void {
                        imgX = e.x - distX;
                        imgY = e.y - distY;
                        if(e.x>=600 and e.x<=800){
                            if(e.y>=565 and e.y<=765){
                               
                                   ct=true        }
                        }
                        if(e.x>=300 and e.x<=450){
                            if(e.y>=600 and e.y<=750){
                                   cta=true  ;
                                   }
                     }
}
                        onMouseReleased: function(e: MouseEvent): Void {
                        if (ct){
                                   imgX=2000;
                                   imgY=2000;
                                   cont=cont+1;
                                   ct=false
                                   
                            }if(cta){
                                imgX=850;
                                imgY=150;
                                 cont=cont-1;
                                 cta=false
                                 }

    }                    }

var dado=ImageView {
var imgX : Number = 5;
var imgY : Number = 10;
var startX : Number;
var startY : Number ;
var distX : Number;
var distY : Number ;
var ct:Boolean
var cta:Boolean
                        x:bind imgX;
                        y:bind imgY;
                        fitWidth:150
                        fitHeight:87
                        image : images[1]
                        onMousePressed: function( e: MouseEvent ):Void {
                        startX = e.x;
                        startY = e.y;
                        distX = startX - imgX;
                        distY = startY - imgY;
                    }
                    onMouseClicked: function(e: MouseEvent): Void {
                    startX=e.x;
                    startY=e.y
}
                    onMouseDragged: function( e: MouseEvent ):Void {
                        imgX = e.x - distX;
                        imgY = e.y - distY;
                        if(e.x>=600 and e.x<=800){
                            if(e.y>=565 and e.y<=765){

                                   ct=true        }
                        }
                        if(e.x>=300 and e.x<=450){
                            if(e.y>=600 and e.y<=750){
                                   cta=true  ;
                                   }
                     }
}
                        onMouseReleased: function(e: MouseEvent): Void {
                        if (ct){
                                   imgX=5;
                                   imgY=10;
                                   cont=cont-1;
                                   ct=false
                            }if(cta){
                                imgX=5;
                                imgY=10;
                                 cont=cont-1;
                                cta=false
                                }
                            

    }                    }
var discos=ImageView{
var imgX : Number = 150;
var imgY : Number = 10;
var startX : Number;
var startY : Number ;
var distX : Number;
var distY : Number ;
var ct;
var cta;
                       x:bind imgX;
                       y:bind imgY;
                        fitWidth:150
                        fitHeight:87
                        image : images[2]
                           onMousePressed: function( e: MouseEvent ):Void {
                        startX = e.x;

                        startY = e.y;

                        distX = startX - imgX;

                        distY = startY - imgY;
                    }
                    onMouseDragged: function( e: MouseEvent ):Void {
                        imgX = e.x - distX;
                        imgY = e.y - distY;
                        if(e.x>=600 and e.x<=800){
                            if(e.y>=565 and e.y<=765){

                                   ct=true        }
                        }
                        if(e.x>=300 and e.x<=450){
                            if(e.y>=600 and e.y<=750){
                                   cta=true  ;
                                   }
                     }
}
                        onMouseReleased: function(e: MouseEvent): Void {
                        if (ct){
                                   imgX=150;
                                   imgY=10;
                                   cont=cont-1;
                                   ct=false
                            }if(cta){
                                imgX=150;
                                imgY=10;
                                 cont=cont-1;
                                cta=false
                                }


    }                    }
var gorrocumple=ImageView {
var imgX : Number = 200;
var imgY : Number = 100;
var startX : Number;
var startY : Number ;
var distX : Number;
var distY : Number ;
var ct:Boolean
var cta:Boolean
                       x:bind imgX;
                       y:bind imgY;
                       fitWidth:120
                       fitHeight:87
                       image :bind images[3]
                       onMousePressed: function( e: MouseEvent ):Void {
                       startX = e.x;
                       startY = e.y;
                       distX = startX - imgX;
                       distY = startY - imgY;
                    }

                       onMouseClicked: function(e: MouseEvent): Void {
                       startX=e.x;
                       startY=e.y
}                      onMouseDragged: function( e: MouseEvent ):Void {
                        imgX = e.x - distX;
                        imgY = e.y - distY;
                        if(e.x>=600 and e.x<=800){
                            if(e.y>=565 and e.y<=765){

                                   cta=true        }
                        }
                        if(e.x>=300 and e.x<=450){
                            if(e.y>=600 and e.y<=750){
                                   ct=true  ;
                                   }
                     }
}
                        onMouseReleased: function(e: MouseEvent): Void {
                        if (ct){
                                   imgX=2000;
                                   imgY=2000;
                                   cont=cont+1;
                                   ct=false
                            }if(cta){
                                imgX=157;
                                imgY=87;
                                 cont=cont-1;
                                cta=false
                                }


    }                    }

var lata=ImageView {
var imgX : Number = 250;
var imgY : Number = 10;
var startX : Number;
var startY : Number ;
var distX : Number;
var distY : Number ;
var ct;
var cta;
                       x:bind imgX;
                       y:bind imgY;

                        fitWidth:150
                        fitHeight:87
                        image : images[4]
                              onMousePressed: function( e: MouseEvent ):Void {
                        startX = e.x;

                        startY = e.y;

                        distX = startX - imgX;

                        distY = startY - imgY;
                    }
                    onMouseDragged: function( e: MouseEvent ):Void {
                        imgX = e.x - distX;
                        imgY = e.y - distY;
                        if(e.x>=600 and e.x<=800){
                            if(e.y>=565 and e.y<=765){

                                   ct=true        }
                        }
                        if(e.x>=300 and e.x<=450){
                            if(e.y>=600 and e.y<=750){
                                   cta=true  ;
                                   }
                     }
}
                        onMouseReleased: function(e: MouseEvent): Void {
                        if (ct){
                                   imgX=250;
                                   imgY=10;
                                   cont=cont-1;
                                   ct=false
                            }if(cta){
                                imgX=250;
                                imgY=10;
                                 cont=cont-1;
                                cta=false
                                }


    }                    }
var late=ImageView {
var imgX : Number = 400;
var imgY : Number = 10;
var startX : Number;
var startY : Number ;
var distX : Number;
var distY : Number ;
var ct:Boolean
var cta:Boolean
                       x:bind imgX;
                       y:bind imgY;

                        fitWidth:150
                        fitHeight:87
                        image : images[5]
                              onMousePressed: function( e: MouseEvent ):Void {
                        startX = e.x;

                        startY = e.y;

                        distX = startX - imgX;

                        distY = startY - imgY;
                    }
                    onMouseDragged: function( e: MouseEvent ):Void {
                             imgX = e.x - distX;
                        imgY = e.y - distY;
                        if(e.x>=600 and e.x<=800){
                            if(e.y>=565 and e.y<=765){

                                   ct=true        }
                        }
                        if(e.x>=300 and e.x<=450){
                            if(e.y>=600 and e.y<=750){
                                   cta=true  ;
                                   }
                     }
}
                        onMouseReleased: function(e: MouseEvent): Void {
                        if (ct){
                                   imgX=2000;
                                   imgY=2000;
                                   cont=cont+1;
                                   ct=false
                            }if(cta){
                                imgX=400;
                                imgY=10;
                                 cont=cont-1;
                                cta=false
                                }
                            

    }                    }
var pelota=ImageView {
var imgX : Number = 550;
var imgY : Number = 10;
var startX : Number;
var startY : Number ;
var distX : Number;
var distY : Number ;
var ct;
var cta;
                       x:bind imgX;
                       y:bind imgY;

                        fitWidth:150
                        fitHeight:87
                        image : images[6]
                              onMousePressed: function( e: MouseEvent ):Void {
                        startX = e.x;

                        startY = e.y;

                        distX = startX - imgX;

                        distY = startY - imgY;
                    }
                    onMouseDragged: function( e: MouseEvent ):Void {
                                               imgX = e.x - distX;
                        imgY = e.y - distY;
                        if(e.x>=600 and e.x<=800){
                            if(e.y>=565 and e.y<=765){

                                   ct=true        }
                        }
                        if(e.x>=300 and e.x<=450){
                            if(e.y>=600 and e.y<=750){
                                   cta=true  ;
                                   }
                     }
}
                        onMouseReleased: function(e: MouseEvent): Void {
                        if (ct){
                                   imgX=550;
                                   imgY=10;
                                   cont=cont-1;
                                   ct=false
                            }if(cta){
                                imgX=550;
                                imgY=10;
                                 cont=cont-1;
                                cta=false
                                }


    }                    }
var tarropapa=ImageView {
var imgX : Number = 700;
var imgY : Number = 10;
var startX : Number;
var startY : Number ;
var distX : Number;
var distY : Number ;
var ct;
var cta;
                       x:bind imgX;
                       y:bind imgY;

                        fitWidth:150
                        fitHeight:87
                        image : images[7]
                              onMousePressed: function( e: MouseEvent ):Void {
                        startX = e.x;

                        startY = e.y;

                        distX = startX - imgX;

                        distY = startY - imgY;
                    }
                    onMouseDragged: function( e: MouseEvent ):Void {
                                               imgX = e.x - distX;
                        imgY = e.y - distY;
                        if(e.x>=600 and e.x<=800){
                            if(e.y>=565 and e.y<=765){

                                   ct=true        }
                        }
                        if(e.x>=300 and e.x<=450){
                            if(e.y>=600 and e.y<=750){
                                   cta=true  ;
                                   }
                     }
}
                        onMouseReleased: function(e: MouseEvent): Void {
                        if (ct){
                                   imgX=700;
                                   imgY=10;
                                   cont=cont-1;
                                   ct=false
                            }if(cta){
                                imgX=700;
                                imgY=10;
                                 cont=cont-1;
                                cta=false
                                }


    }                    }
var torrecd=ImageView {
var imgX : Number = 800;
var imgY : Number = 10;
var startX : Number;
var startY : Number ;
var distX : Number;
var distY : Number ;
var ct:Boolean;
var cta:Boolean;
                        x:bind imgX;
                       y:bind imgY;

                        fitWidth:150
                        fitHeight:87
                        image : images[8]
                              onMousePressed: function( e: MouseEvent ):Void {
                        startX = e.x;

                        startY = e.y;

                        distX = startX - imgX;

                        distY = startY - imgY;
                    }
                    onMouseDragged: function( e: MouseEvent ):Void {
                             imgX = e.x - distX;
                        imgY = e.y - distY;
                        if(e.x>=600 and e.x<=800){
                            if(e.y>=565 and e.y<=765){

                                   ct=true        }
                        }
                        if(e.x>=300 and e.x<=450){
                            if(e.y>=600 and e.y<=750){
                                   cta=true  ;
                                   }
                     }
}
                        onMouseReleased: function(e: MouseEvent): Void {
                        if (ct){
                                   imgX=2000;
                                   imgY=2000;
                                   cont=cont+1;
                                   ct=false
                            }if(cta){
                                imgX=800;
                                imgY=10;
                                 cont=cont-1;
                                cta=false
                                }
                            

    }                    }

var vela=ImageView {
var imgX : Number = 900;
var imgY : Number = 10;
var startX : Number;
var startY : Number ;
var distX : Number;
var distY : Number ;
var ct:Boolean;
var cta:Boolean
                       x: bind imgX;
                       y: bind imgY;
                        fitWidth:150
                        fitHeight:87
                        image : images[9]
                              onMousePressed: function( e: MouseEvent ):Void {
                        startX = e.x;

                        startY = e.y;

                        distX = startX - imgX;

                        distY = startY - imgY;
                    }
                    onMouseDragged: function( e: MouseEvent ):Void {
                             imgX = e.x - distX;
                        imgY = e.y - distY;

                           if(e.x>=300 and e.x<=450){
                            if(e.y>=600 and e.y<=750){
                                   ct=true  ;
                                   }
                     }
                       if(e.x>=600 and e.x<=800){
                            if(e.y>=565 and e.y<=765){

                                   cta=true        }
                        }
                    
}
                        onMouseReleased: function(e: MouseEvent): Void {
                        if (ct){
                                   imgX=2000;
                                   imgY=2000;
                                   cont=cont+1;
                                   ct=false
                            }if(cta){
                                imgX=900;
                                imgY=10;
                                 cont=cont-1;
                                 cta=false
                                }
                            

    }                    }

var cono=ImageView {
                        y:600
                        x:300
                        fitWidth:203
                        fitHeight:186

                        image : images[10]

}
var prisma=ImageView {
                        y:565
                        x:600
                        fitWidth:203
                        fitHeight:186

                        image : images[11]

}



Stage {
    title: "Application title"
    scene: Scene {
        width: 1024
        height: 768
        content: [

           ImageView {
                x: 300.0, y: 200.0
                fitWidth:500
                fitHeight:320
                image: Image {
		url: "{__DIR__}baultaparriba.png"
	}
}
Button {
        translateX:900;
        translateY:600;
	text: "Button"
	action: function() {
            
	}
}

prisma,cono,
contador,grupo

        ]
    }
    var grupo=Group {
	content: [
		dado,vela,torrecd,tarropapa,pelota,late,lata,gorrocumple,discos,cajate

	]
}
}
